import store from "../../store/index"

// 认识状态
// dispatch：更改状态
// subscribe：订阅状态更改
function DispatchStore() {

    // 订阅：注册状态改变
    store.subscribe(() =>
        console.log(store.getState())
    );


    return (
        <div>
            <h1>认识状态</h1>
            <button onClick={() => store.dispatch({ type: 'INCREMENT' })}>+</button>
            <button onClick={() => store.dispatch({ type: 'DECREMENT' })}>-</button>
        </div>
    )

}

export default DispatchStore;